package app.beit.fintrack.service.convert;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import app.beit.fintrack.bean.summary.SummaryTrackAppealBean;
import app.beit.fintrack.entity.summary.SummaryTrackAppeal;

public class SummaryTrackAppealConvert {

	/**
	 * Convert Entity To Bean
	 * 
	 * @param entity
	 * @return SummaryTrackAppealBean
	 */
	public static SummaryTrackAppealBean entityToBean(final SummaryTrackAppeal entity) {
		final SummaryTrackAppealBean bean = new SummaryTrackAppealBean();

		bean.setTotal(entity.getTotal() == null || entity.getTotal().toString().equalsIgnoreCase("") ? new BigDecimal("0") : entity.getTotal());
		bean.setAmount(entity.getAmount() == null || entity.getAmount().toString().equalsIgnoreCase("") ? new BigDecimal("0") : entity.getAmount());
		bean.setFund(entity.getFund());
		bean.setTranId(entity.getTranId());
		
		return bean;
	}

	/**
	 * Convert Bean to Entity
	 * 
	 * @param bean
	 * @return SummaryTrackAppeal
	 */
	public static SummaryTrackAppeal beanToEntity(final SummaryTrackAppealBean bean){
		final SummaryTrackAppeal entity = new SummaryTrackAppeal();

		entity.setTotal(bean.getTotal() == null || bean.getTotal().toString().equalsIgnoreCase("") ? new BigDecimal("0") : bean.getTotal());
		entity.setAmount(bean.getAmount() == null || bean.getAmount().toString().equalsIgnoreCase("") ? new BigDecimal("0") : bean.getAmount());
		entity.setFund(bean.getFund());
		entity.setTranId(bean.getTranId());

		return entity;
	}

	/**
	 * Convert List Entity to List Bean
	 * 
	 * @param entities
	 * @return List SummaryTrackAppealBean
	 */
	public static List<SummaryTrackAppealBean> entityToBean(final List<SummaryTrackAppeal> entities){
		final List<SummaryTrackAppealBean> beans = new ArrayList<SummaryTrackAppealBean>();

		for (final SummaryTrackAppeal entity : entities) {
			beans.add(SummaryTrackAppealConvert.entityToBean(entity));
		}

		return beans;
	}

	/**
	 * Convert List Bean to List Entity
	 * 
	 * @param beans
	 * @return List SummaryTrackAppeal
	 */
	public static List<SummaryTrackAppeal> beanToEntity(final List<SummaryTrackAppealBean> beans){
		final List<SummaryTrackAppeal> entities = new ArrayList<SummaryTrackAppeal>();

		for (final SummaryTrackAppealBean bean : beans) {
			entities.add(SummaryTrackAppealConvert.beanToEntity(bean));
		}

		return entities;
	}

}
